package com.oil.petro.eshop.service;

import com.oil.petro.eshop.dao.CategoryDAO;
import com.oil.petro.eshop.entity.Category;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional()/**/

public class CategoryServiceImpl implements CategoryService {

    @Autowired
    CategoryDAO categoryDAO;

    @Override
    public Category getCategory(int id) {
        return categoryDAO.get(id);
    }

    @Override
    public void deleteCategory(Category category) {
        categoryDAO.delete(category);
    }

    @Override
    public int saveCategory(Category category) {
        return categoryDAO.save(category);
    }

    @Override
    public void updateCategory(Category category) {
        categoryDAO.update(category);
    }

    @Override
    public List<Category> getCategoryList() {
        return categoryDAO.getList();
    }

    @Override
    public int getCategoryIdByName(String name) {
        return categoryDAO.getId(name);
    }
}
